package com.fary.beans;


import com.fary.core.SpringException;
import com.fary.core.convert.TypeDescriptor;

import java.util.Map;

public interface PropertyAccessor {

    /**
     * Path separator for nested properties.
     * Follows normal Java conventions: getFoo().getBar() would be "foo.bar".
     */
    String NESTED_PROPERTY_SEPARATOR = ".";

    /**
     * Path separator for nested properties.
     * Follows normal Java conventions: getFoo().getBar() would be "foo.bar".
     */
    char NESTED_PROPERTY_SEPARATOR_CHAR = '.';

    /**
     * Marker that indicates the start of a property key for an
     * indexed or mapped property like "person.addresses[0]".
     */
    String PROPERTY_KEY_PREFIX = "[";

    /**
     * Marker that indicates the start of a property key for an
     * indexed or mapped property like "person.addresses[0]".
     */
    char PROPERTY_KEY_PREFIX_CHAR = '[';

    /**
     * Marker that indicates the end of a property key for an
     * indexed or mapped property like "person.addresses[0]".
     */
    String PROPERTY_KEY_SUFFIX = "]";

    /**
     * Marker that indicates the end of a property key for an
     * indexed or mapped property like "person.addresses[0]".
     */
    char PROPERTY_KEY_SUFFIX_CHAR = ']';

    boolean isReadableProperty(String propertyName);

    boolean isWritableProperty(String propertyName);

    Class<?> getPropertyType(String propertyName) throws SpringException;

    TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws SpringException;

    Object getPropertyValue(String propertyName) throws SpringException;

    void setPropertyValue(String propertyName, Object value) throws SpringException;

    void setPropertyValue(PropertyValue pv) throws SpringException;

    void setPropertyValues(Map<?, ?> map) throws SpringException;

    void setPropertyValues(PropertyValues pvs) throws SpringException;

    void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown) throws SpringException;

    void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid) throws SpringException;

}